package com.cwg.dict.model;

import java.text.SimpleDateFormat;
import java.util.Date;

public class History implements Comparable<History> {

	private Date	date;
	private boolean	favorite;
	private String	word;

	public History(Date date, String word) {
		this.date = date;
		this.word = word;
	}

	@Override
	public int compareTo(History h) {
		if (h == null || h.getDate() == null) {
			return -1;
		}
		return getDate().compareTo(h.getDate());
	}

	public Date getDate() {
		return date;
	}

	public String getWord() {
		return word;
	}

	public boolean isFavorite() {
		return favorite;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setFavorite(boolean favorite) {
		this.favorite = favorite;
	}

	public void setWord(String word) {
		this.word = word;
	}

	@Override
	public String toString() {
		// Using CSV as store format
		String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
		return formattedDate + ", " + word + ", " + isFavorite();
	}

}